#ifndef PLUGINSTABLEDELEGATE_H
#define PLUGINSTABLEDELEGATE_H

#include <QStyledItemDelegate>
#include <QPainter>
#include <QEvent>
#include <QPersistentModelIndex>


class PluginsTableDelegate : public QStyledItemDelegate
{
	Q_OBJECT
private:
	enum State{
		Normal,
		Hovered,
		Pressed
	};

	QPixmap m_loaded;
	QPixmap m_unloaded;
	int m_buttonColumn;

	QPersistentModelIndex  m_lastUnderMouse;
public:
	PluginsTableDelegate(QObject *parent = 0);
	QSize sizeHint(const QStyleOptionViewItem &option,
				   const QModelIndex &index) const;
	void paint(QPainter *painter, const QStyleOptionViewItem &option,
			   const QModelIndex &index) const;

protected:
	bool editorEvent(QEvent *event, QAbstractItemModel *model,
					 const QStyleOptionViewItem &option,
					 const QModelIndex &index);

signals:
	void needsUpdate(const QModelIndex &index);
	void clicked(const QModelIndex &index);

public slots:
	void mouseLeave();
};

#endif // PLUGINSTABLEDELEGATE_H

